#include <stdio.h>

int icount = 0;

int Hanoi_count(int n) {
    if (n > 1) {
        return 2 * Hanoi_count(n - 1) + 1;
    } else {
        return 1;
    }
}

void Hanois(int N, char a, char b, char c) {
    if (N >= 1) {
        Hanois(N - 1, a, c, b);
        printf("Step:%d Move Disk%d from %c to %c\n", icount + 1, N, a, c);
        Hanois(N - 1, b, a, c);
    }
}

int main() {
    int num;
    printf("请输入层数:>");
    scanf("%d", &num);
    int ret = Hanoi_count(num);
    Hanois(num, 'A', 'B', 'C');
    printf("移动的总次数为:%d", ret);
    return 0;
}